package com.usian.controller;

import com.usian.pojo.*;
import com.usian.service.DeptService;
import com.usian.service.EmpService;
import com.usian.service.ZhiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;

@Controller
@RequestMapping("t")
public class TController {
    @Autowired
    private EmpService empService;
    @Autowired
    private DeptService deptService;
    @Autowired
    private ZhiService zhiService;
    @RequestMapping("tologin")
    public String tologin(){
        return "login";
    }
    @RequestMapping("toemp")
    public String toEmp(Model model, HttpServletRequest request){
        Integer rid = (Integer) request.getSession().getAttribute("rid");
        if (rid==2) {
            return "emp";
        }
return "emp2";

    }
    @RequestMapping("toadddept")
    public String toAddDept(){
        return "adddept";
    }
    @RequestMapping("todept")
    public String toDept(Model model){
        List<Dept> list=empService.findDept();
        model.addAttribute("list",list);
        return "dept";
    }
    @RequestMapping("tozhi")
    public String toZhi(Model model,HttpSession session){
        List<Zd> list= empService.findzhi();
        model.addAttribute("list",list);
        return "zhi";
    }
}
